const db = require('./index')


module.exports = {
    getOrder: async (user_id = '') => {
        const sql = `select * from orders where user_id = ? order by order_time desc`;
        return await db.query(sql, user_id)
    },
    addOrder: async (len, data) => {
        let sql = ` insert into orders values(null,?,?,?,?,?,?)`;
        for (i = 0; i < len - 1; i++) {
            sql += ",(null,?,?,?,?,?,?)"
        }
        return await db.query(sql, data)
    },
    getAllOrder: async (user_id) => {
        const sql = ` select order_id from orders where user_id = ? group by order_id desc `;
        return await db.query(sql,user_id);
    }
}